package org.example.subject2;

import java.util.ArrayList;
import java.util.List;

/**
 * @author brant
 */
public class ListNode {

    int val;
    ListNode next;

    ListNode() {}

    ListNode(int val) { this.val = val; }

    ListNode(int val, ListNode next) { this.val = val; this.next = next; }

    @Override
    public String toString() {
        List<Integer> list = new ArrayList<>();
        list.add(val);
        while(next != null) {
            list.add(next.val);
            next = next.next;
        }
        return list.toString();
    }
}
